/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.lnu.ums.dal.impl;

import edu.lnu.ums.dal.INoConcurrentAccessGenericDAO;
import edu.lnu.ums.entities.core.AbstractEntity;
import javax.persistence.EntityManager;

/**
 *
 * @author Renuald
 */
public abstract class AbstractNoConcurrentAccessGenericDAO<T extends AbstractEntity> extends AbstractGenericDAO<T> implements INoConcurrentAccessGenericDAO<T>{

    public AbstractNoConcurrentAccessGenericDAO(Class<T> cls) {
        super(cls);
    }

    @Override
    public T merge(T obj) {
        EntityManager em = obj.getFactory().createEntityManager();
        em.getTransaction().begin();
        T t = em.merge(obj);
        em.getTransaction().commit();
        return t;
    }

}
